gameData = gameData or {}

gameData.level = 1
gameData.leveldata = {}
gameData.historyScore = 0
gameData.curScore = 0
gameData.curStars = 0

gameData.status = pp.gamestate_playing

gameData.level_needPopLevelInfoPanel = false

gameData.award = {
	coin = 0,
	fenji = 0,
	yuheng = 0,
}

gameData.changeSceneTimes = {
	levelScene = 0,
	gameScene = 0
}

function gameData:initForApp()

	self.loginChecked = false
	---------------------------------
	self:initForGame()
end

function gameData:initForGame()
	self.curScore = 0
	self.curStars = 0
	self.status = pp.gamestate_readyGoing
	self.fuhuoTimes = 0

	self.award.coin = 0
	self.award.fenji = 0
	self.award.yuheng = 0
end

-- function gameData:nextLevel()
--     self.level = self.level + 1
--     if self.level > 24 then
--         self.level = 1
--     end
    
--     return self.level
-- end

function gameData:genAward()
	if self.leveldata and self.leveldata.award then
        local basecoin = math.random(self.leveldata.award.coin[1],self.leveldata.award.coin[2])
		
		local award = self.leveldata.award[self.curStars]       
		if not award then
		  d_print("award == nil")
		end
        self.award.coin = math.ceil(basecoin*award.c_rate)
		self.award.fenji = award.fenji[math.random(#award.fenji)]
		self.award.yuheng = award.yuheng[math.random(#award.yuheng)]
	else
		self.award.coin = 0
		self.award.fenji = 0
		self.award.yuheng = 0
	end
end

------------------------------------------------------

gameData.SwichByServer = {
	popChangWanLiBao = false,
	LicenseMode = true,
	popXinShouLiBao = false,
}


--从后台取是否在进levelScene时弹出畅玩礼包
function gameData:checkSwichInfo_callJava()
	-- body
	for k,v in pairs(gameData.SwichByServer) do
		local args = {k}
		local sigs = "(Ljava/lang/String;)V"
		local className = "org/cocos2dx/lua/AppActivity"

		local ok = luaj.callStaticMethod(className, "s_GltGetInfo_fromLua", args, sigs)

		if not ok then
			d_print("checkSwichInfo_callJava error")
		end
	end
end

function retPopChangWanLiBao_fromJava(retStr)
	if retStr == "yes" then
        d_print("PopChangWanLiBao----yes")
		gameData.SwichByServer.popChangWanLiBao = true
	else
		d_print("PopChangWanLiBao----no")
		gameData.SwichByServer.popChangWanLiBao = false
	end
end

function retLicenseMode_fromJava(retStr)
	--special : glt默认返回false，这里先反过来，日后再调整 !!!!!!!!!!!
	if retStr == "yes" then
        d_print("LicenseMode----yes")
		gameData.SwichByServer.LicenseMode = false
	else
		d_print("LicenseMode----no")
		gameData.SwichByServer.LicenseMode = true
	end
end

function retPopXinShouLiBao_fromJava(retStr)
	if retStr == "yes" then
        d_print("popXinShouLiBao----yes")
		gameData.SwichByServer.popXinShouLiBao = true
	else
		d_print("popXinShouLiBao----no")
		gameData.SwichByServer.popXinShouLiBao = false
	end
end